package singleton;

/**
 * 饿汉式
 *
 * 1. 构造方法私有
 * 2. 声明一个未初始化的静态变量
 * 3. 静态代码块初始化变量
 * 4. 静态方法返回静态变量
 */
public class Singleton03 {

    private static Singleton03 INSTANCE = null;

    static {
        INSTANCE = new Singleton03();
    }

    private Singleton03(){}

    public static Singleton03 getInstance(){
        return INSTANCE;
    }


    public static void main(String[] args) {
        Singleton03 i1 = Singleton03.getInstance();
        Singleton03 i2 = Singleton03.getInstance();
        System.out.println(i1 == i2);
    }
}
